#include "GetPipe.hpp"
#include <fcntl.h>

#define NUM 1024
int main()
{
    CrePipeFile fifo;

    int fd = open(PIPE_FILE,O_RDONLY);
    if(fd < 0)
    {
        perror("open");
        exit(errno);
    }
    while(true)
    {
        char buffer[NUM];
        int n = read(fd,buffer,sizeof(buffer));
        if( n < 0)
        {
            perror("read");
            exit(errno);
        }
        else if(n == 0)
        {
            printf("写端退出\n");
            break;
        }
        buffer[n] = 0;
        std::cout << "接收到的内容:"<<buffer << std::endl;
    }
    close(fd);
    return 0;
}